home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 12 / 012.d81 / dos #29 < prev    next >
Text File  |  2022-08-26  |  3KB  |  207 lines

  1.  
  2.        DOS & Don'ts -- Part 29
  3.           by Jimmy Weiler
  4.  
  5.  
  6. ======================================
  7. Now even YOUR programs can read the
  8. directory.
  9. ======================================
  10.  
  11.  
  12.   We haven't said much about the
  13.  
  14. directory since Part 7.
  15.  
  16.   I am just going to assume that you
  17.  
  18. all know how to LOAD "$",8 then LIST
  19.  
  20. to look at what files are on your
  21.  
  22. disk.  This installment of DOS &
  23.  
  24. Don'ts will show you how to make your
  25.  
  26. PROGRAMS read and display a directory.
  27.  
  28.   This time, I break with tradition
  29.  
  30. and show you the simple way to do it
  31.  
  32. first.
  33.  
  34. 1.  Install the DOS wedge.
  35.  
  36. 2.  Where you want your program to
  37.     display the directory, enter this
  38.     instruction:  @"$"
  39.  
  40.  
  41.   You can get fancy with the wedge:
  42.  
  43. To display only the SEQ files: @"$*=S"
  44.  
  45. To display only the PRG files: @"$*=P"
  46.  
  47. To display only the REL files: @"$*=R"
  48.  
  49. To display only the USR files: @"$*=U"
  50.  
  51. To display only files beginning with
  52.  
  53. any pattern, use the wild card, "*".
  54.  
  55. @"$T.*" will show only files prefixed
  56.  
  57. by "T."
  58.  
  59.   You can mix these concepts, too:
  60.  
  61. @"$TEXT*=S" will show only those
  62.  
  63. sequential files whose names start
  64.  
  65. with "TEXT".
  66.  
  67.   Okay, enough of the easy stuff.  Now
  68.  
  69. I'll show you the hard way to do the
  70.  
  71. same thing.
  72.  
  73.   The 1541 User's Manual says you can
  74.  
  75. read the directory just like a
  76.  
  77. SEQuential file.  That's true.
  78.  
  79. Unfortunately, the directory reading
  80.  
  81. program listed in that manual doesn't
  82.  
  83. work.  Fortunately, LOADSTAR now
  84.  
  85. provides you with a version that DOES
  86.  
  87. work on the 1541 drive.  Look for it
  88.  
  89. in the directory under the name
  90.  
  91. Q&D DIR DISPLAY.
  92.  
  93.   Here's a blow-by-blow account of how
  94.  
  95. Q&D DIR DISPLAY works:
  96.  
  97.  
  98. 1020 OPEN15,8,15,"I0"
  99.  
  100.   We initialize the disk.  It is
  101.  
  102. possible that the disk we are about to
  103.  
  104. read was just placed in the drive.
  105.  
  106. This will help prevent DISK ID
  107.  
  108. MISMATCHes in that case.
  109.  
  110.  
  111. 1030 Z$=CHR$(0): IL$=CHR$(128):
  112.      Q$=CHR$(34): SP$=CHR$(160)
  113.  
  114.   We declare some variables:
  115.  
  116.   Z$ is used later when we evaluate
  117.  
  118. ASCii value of the result of a GET#.
  119.  
  120. If you GET# a ZERO character, the ASC
  121.  
  122. function won't work.  To prevent
  123.  
  124. ILLEGAL QUANTITY ERRORs, we can
  125.  
  126. concatenate Z$ to the variable we GET
  127.  
  128. before we evaluate the variable:
  129.  
  130. e.g.  GET#8,K$:PRINT ASC(K$+Z$)
  131.  
  132.   Q$ is defined as the quote symbol.
  133.  
  134. We use it later to bracket file names
  135.  
  136. as we print them.
  137.  
  138.   SP$ is a shifted space.  In the
  139.  
  140. directory, every file name less than
  141.  
  142. 16 characters long ends with
  143.  
  144. shifted spaces.
  145.  
  146.  
  147. 1040 DIM F$(29)
  148.  
  149.   We will use array F$ to assemble
  150.  
  151. file names.  Each name uses 29 bytes
  152.  
  153. of the directory.
  154.  
  155.  
  156. 1050 TY$(0)="DEL": TY$(1)="SEQ":
  157.      TY$(2)="PRG": TY$(3)="USR":
  158.      TY$(4)="REL"
  159.  
  160.   Here we declare file types.
  161.  
  162.  
  163. 1060 OPEN8,8,8,"$"
  164.  
  165.   We open the directory as a file.
  166.  
  167.  
  168. 1070 BU=0
  169.  
  170.   BU is our "BLOCKS USED" counter.
  171.  
  172. We set it to zero before we start
  173.  
  174. reading the directory.
  175.  
  176.  
  177. 1080 FOR C1=1 TO 142: GET#8,K$: NEXT
  178.  
  179.   The first 142 characters of the
  180.  
  181. directory are not interesting to us
  182.  
  183. at this point so we skip over them.
  184.  
  185. (The third through 142nd characters
  186.  
  187. make up the BLOCK AVAILABILITY MAP.)
  188.  
  189.  
  190.  
  191. 1090 PRINT "NAME:<rvon>";:FOR C1=144
  192.      TO 160: GET#8,K$:PRINT K$;: NEXT:
  193.      PRINT"<rvof> ";
  194.  
  195.   The next eighteen characters of
  196.  
  197. the directory are the disk name.  We
  198.  
  199. print that in reverse.
  200.  
  201.  
  202. 1100 GET#8,L$,M$,N$: PRINT"ID:"M$,N$
  203.  
  204.   We read and print the disk ID.
  205.  
  206. -------< continued in Part 30 >-------
  207.